package utils.beanUtils;

import domain.Student;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by think on 2016/6/22.
 */
public class BeanUtilsTest {
    public static void main(String[] args) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        //数据目的
        Student student = new Student();
        //数据源1
        Map map1 = new HashMap<>();
        map1.put("sname","yanglh");
        //数据源2
        Map map2 = new HashMap<>();
        map2.put("sid","10002923");
        //将多出数据源汇总到数据目的student
        BeanUtils.copyProperties(student,map1);
        BeanUtils.copyProperties(student,map2);
        System.out.println(student);
    }
}
